import sys

# 文件路径和要检查的行号
file_path = r"managed_components/cfscn__sensorlib/src/SensorQMI8658.hpp"
lines_to_check = [1764, 1766, 1840, 1842]

# 读取文件内容
with open(file_path, 'r', encoding='utf-8') as f:
    lines = f.readlines()

changed = False
for idx in lines_to_check:
    # 行号从1开始
    if idx <= len(lines):
        if 'Serial.println' in lines[idx-1]:
            lines[idx-1] = lines[idx-1].replace('Serial.println', 'log_i')
            changed = True

if changed:
    with open(file_path, 'w', encoding='utf-8') as f:
        f.writelines(lines)
    print(f"Replaced Serial.println with log_i in lines: {lines_to_check}")
else:
    print("No Serial.println found in specified lines.")
